package com.nearbymap.maps;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.xpath.XPathFactory;

import org.springframework.stereotype.Service;

@Service
public class DistanceMatrixService {
	XPathFactory factory = XPathFactory.newInstance();

	public URL getPlacesUrl(String origins, String destinations, String mode) throws MalformedURLException {
			StringBuffer urlBuffer = 
					new StringBuffer("https://maps.googleapis.com/maps/api/place/distancematrix/xml?origins=").append(origins)
					.append("&destinations=").append(destinations);
			if(mode != null)
				urlBuffer.append("&mode=").append(mode);
			urlBuffer.append("&sensor=false&key=AIzaSyAdknM5MFaotgggSTAAPEU7WezHoENIv9U");
			return new URL(urlBuffer.toString());
	}
}
